
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.SwingWorker;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author jy
 */
public class RMMExcute extends SwingWorker<String, Object> {
    private String m_str = null;
    private JTextArea m_jta; 
    private long m_usedTime = -1;
    
    public RMMExcute(){}
    
    public RMMExcute(String str, JTextArea jta)
    {
        m_str = str;
        m_jta = jta;
    }
    
    @Override
    protected String doInBackground()
    {
        long startTime = System.currentTimeMillis();
        ReverseMaxMatching rmm = new ReverseMaxMatching(3);
        rmm.reverseMaxMatching(m_str);
        long endTime = System.currentTimeMillis();
        m_usedTime = endTime - startTime;
        return rmm.getResult();
    }
    
    @Override
    protected void done()
    {
        try
        {
            m_jta.setText(get());
        } catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }
    
    public long getUsedTime()
    {
        return m_usedTime;
    }
}
